﻿<span style='font-size:11px; color:#000000; background:#ffffff; '><pre>
<span style='color:#800000; font-weight:bold; '>protected</span> <span style='color:#800000; font-weight:bold; '>void</span> createPdfButton_Click<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>object</span> sender<span style='color:#808030; '>,</span> EventArgs e<span style='color:#808030; '>)</span>
<span style='color:#800080; '>{</span>
    <span style='color:#696969; '>// Create a PDF document</span>
    Document pdfDocument <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> Document<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

    <span style='color:#696969; '>// Set license key received after purchase to use the converter in licensed mode</span>
    <span style='color:#696969; '>// Leave it not set to use the converter in demo mode</span>
    pdfDocument<span style='color:#808030; '>.</span>LicenseKey <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>4W9+bn19bn5ue2B+bn1/YH98YHd3d3c=</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>

    <span style='color:#696969; '>// Add a page to PDF document</span>
    PdfPage pdfPage <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>AddPage<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>try</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#696969; '>// The font used for titles in PDF document</span>
        PdfFont titlesFont <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>AddFont<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>new</span> Font<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Times New Roman</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> FontStyle<span style='color:#808030; '>.</span>Bold<span style='color:#808030; '>,</span> GraphicsUnit<span style='color:#808030; '>.</span>Point<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// The font used for field names in PDF document</span>
        PdfFont fieldNameFont <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>AddFont<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>new</span> Font<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Times New Roman</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> FontStyle<span style='color:#808030; '>.</span>Regular<span style='color:#808030; '>,</span> GraphicsUnit<span style='color:#808030; '>.</span>Point<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// The font used for buttons text in PDF document</span>
        PdfFont buttonTextFont <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>AddFont<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>new</span> Font<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Times New Roman</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> FontStyle<span style='color:#808030; '>.</span>Regular<span style='color:#808030; '>,</span> GraphicsUnit<span style='color:#808030; '>.</span>Point<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// The font used for PDF form text box fields</span>
        PdfFont textFieldFont <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>AddFont<span style='color:#808030; '>(</span>StdFontBaseFamily<span style='color:#808030; '>.</span>Helvetica<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textFieldFont<span style='color:#808030; '>.</span>Size <span style='color:#808030; '>=</span> <span style='color:#008c00; '>8</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// The font used for PDF form combo box fields</span>
        PdfFont comboBoxFieldFont <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>AddFont<span style='color:#808030; '>(</span>StdFontBaseFamily<span style='color:#808030; '>.</span>Helvetica<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        comboBoxFieldFont<span style='color:#808030; '>.</span>Size <span style='color:#808030; '>=</span> <span style='color:#008c00; '>8</span><span style='color:#800080; '>;</span>

        <span style='color:#800000; font-weight:bold; '>float</span> xLocation <span style='color:#808030; '>=</span> <span style='color:#008c00; '>5</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>float</span> yLocation <span style='color:#808030; '>=</span> <span style='color:#008c00; '>5</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add document title</span>
        TextElement titleTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Create PDF Forms</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> titlesFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        AddElementResult addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>titleTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>15</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add a text box field to PDF form</span>
        TextElement fieldNameTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>60</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>First name:</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> fieldNameFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>fieldNameTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        RectangleF fieldNameRectangle <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#800080; '>;</span>
        RectangleF fieldBoundingRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>150</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>15</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the form field</span>
        PdfFormTextBox textBoxField <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Form<span style='color:#808030; '>.</span>AddTextBox<span style='color:#808030; '>(</span>pdfPage<span style='color:#808030; '>,</span> fieldBoundingRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Enter First Name</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> textFieldFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set unique form field name used when the form is submitted</span>
        textBoxField<span style='color:#808030; '>.</span>Name <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>firstName</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set the form field default value</span>
        textBoxField<span style='color:#808030; '>.</span>DefaultValue <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>A default first name</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set form field style </span>
        textBoxField<span style='color:#808030; '>.</span>Style<span style='color:#808030; '>.</span>BackColor <span style='color:#808030; '>=</span> Color<span style='color:#808030; '>.</span>AliceBlue<span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> fieldNameRectangle<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add a text box field to PDF form</span>
        fieldNameTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>60</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Last name:</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> fieldNameFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>fieldNameTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        fieldNameRectangle <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#800080; '>;</span>
        fieldBoundingRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>150</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>15</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the form field</span>
        textBoxField <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Form<span style='color:#808030; '>.</span>AddTextBox<span style='color:#808030; '>(</span>pdfPage<span style='color:#808030; '>,</span> fieldBoundingRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Enter Last Name</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> textFieldFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set unique form field name used when the form is submitted</span>
        textBoxField<span style='color:#808030; '>.</span>Name <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>lastName</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set the form field default value</span>
        textBoxField<span style='color:#808030; '>.</span>DefaultValue <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>A default last name</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set form field style </span>
        textBoxField<span style='color:#808030; '>.</span>Style<span style='color:#808030; '>.</span>BackColor <span style='color:#808030; '>=</span> Color<span style='color:#808030; '>.</span>MistyRose<span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> fieldNameRectangle<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add a password text box field to PDF form</span>
        fieldNameTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>60</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Password:</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> fieldNameFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>fieldNameTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        fieldNameRectangle <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#800080; '>;</span>
        fieldBoundingRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>150</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>15</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the form field</span>
        PdfFormTextBox passwordTextBoxField <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Form<span style='color:#808030; '>.</span>AddTextBox<span style='color:#808030; '>(</span>pdfPage<span style='color:#808030; '>,</span> fieldBoundingRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> textFieldFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set unique form field name used when the form is submitted</span>
        passwordTextBoxField<span style='color:#808030; '>.</span>Name <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>password</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set form field style </span>
        passwordTextBoxField<span style='color:#808030; '>.</span>Style<span style='color:#808030; '>.</span>BackColor <span style='color:#808030; '>=</span> Color<span style='color:#808030; '>.</span>AliceBlue<span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set the password mode for the text box</span>
        passwordTextBoxField<span style='color:#808030; '>.</span>IsPassword <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> fieldNameRectangle<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add a radio buttons group to PDF form</span>
        fieldNameTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>60</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Gender:</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> fieldNameFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>fieldNameTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        fieldNameRectangle <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the radio buttons group</span>
        PdfFormRadioButtonsGroup radioButtonsGroup <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Form<span style='color:#808030; '>.</span>AddRadioButtonsGroup<span style='color:#808030; '>(</span>pdfPage<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set unique form field name used when the form is submitted</span>
        radioButtonsGroup<span style='color:#808030; '>.</span>Name <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>gender</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set style of the radio buttons in this group</span>
        radioButtonsGroup<span style='color:#808030; '>.</span>Style<span style='color:#808030; '>.</span>BackColor <span style='color:#808030; '>=</span> Color<span style='color:#808030; '>.</span>AntiqueWhite<span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the first radio button to group</span>
        RectangleF radioButtonRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>50</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the form field</span>
        PdfFormRadioButton radioButtonField <span style='color:#808030; '>=</span> radioButtonsGroup<span style='color:#808030; '>.</span>AddRadioButton<span style='color:#808030; '>(</span>radioButtonRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>male</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> pdfPage<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        fieldNameTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>22</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>30</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Male</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> fieldNameFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>fieldNameTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the second radio button to group</span>
        radioButtonRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>60</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>50</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the form field</span>
        radioButtonField <span style='color:#808030; '>=</span> radioButtonsGroup<span style='color:#808030; '>.</span>AddRadioButton<span style='color:#808030; '>(</span>radioButtonRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>female</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> pdfPage<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        fieldNameTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>72</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>30</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Female</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> fieldNameFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>fieldNameTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Set the selected radio btton in group</span>
        radioButtonsGroup<span style='color:#808030; '>.</span>SetCheckedRadioButton<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>male</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> fieldNameRectangle<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add a checkbox field to PDF form</span>
        fieldNameTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>60</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Vehicle:</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> fieldNameFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>fieldNameTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        fieldNameRectangle <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#800080; '>;</span>
        fieldBoundingRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the form field</span>
        PdfFormCheckBox checkBoxField <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Form<span style='color:#808030; '>.</span>AddCheckBox<span style='color:#808030; '>(</span>pdfPage<span style='color:#808030; '>,</span> fieldBoundingRectangle<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set unique form field name used when the form is submitted</span>
        checkBoxField<span style='color:#808030; '>.</span>Name <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>haveCar</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set form field style </span>
        checkBoxField<span style='color:#808030; '>.</span>Style<span style='color:#808030; '>.</span>BackColor <span style='color:#808030; '>=</span> Color<span style='color:#808030; '>.</span>AntiqueWhite<span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set checkbox field checked state</span>
        checkBoxField<span style='color:#808030; '>.</span>Checked <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>

        fieldNameTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>22</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>50</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>I have a car</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> fieldNameFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>fieldNameTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> fieldNameRectangle<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add a combo box list field to PDF form</span>
        fieldNameTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>60</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Vehicle Type:</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> fieldNameFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>fieldNameTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        fieldNameRectangle <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#800080; '>;</span>
        fieldBoundingRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>50</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>15</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>string</span><span style='color:#808030; '>[</span><span style='color:#808030; '>]</span> comboBoxItems <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> <span style='color:#800000; font-weight:bold; '>string</span><span style='color:#808030; '>[</span><span style='color:#808030; '>]</span> <span style='color:#800080; '>{</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Volvo</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Saab</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Audi</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Opel</span><span style='color:#800000; '>"</span> <span style='color:#800080; '>}</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the form field</span>
        PdfFormComboBox comboBoxField <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Form<span style='color:#808030; '>.</span>AddComboBox<span style='color:#808030; '>(</span>pdfPage<span style='color:#808030; '>,</span> fieldBoundingRectangle<span style='color:#808030; '>,</span> comboBoxItems<span style='color:#808030; '>,</span> comboBoxFieldFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set unique form field name used when the form is submitted</span>
        comboBoxField<span style='color:#808030; '>.</span>Name <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>vehicleType</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set the form field default value</span>
        comboBoxField<span style='color:#808030; '>.</span>DefaultValue <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Audi</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set form field style </span>
        comboBoxField<span style='color:#808030; '>.</span>Style<span style='color:#808030; '>.</span>BackColor <span style='color:#808030; '>=</span> Color<span style='color:#808030; '>.</span>LightCyan<span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set selected item in combo box</span>
        comboBoxField<span style='color:#808030; '>.</span>Value <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Audi</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> fieldNameRectangle<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add a multiline text box field to PDF form</span>
        fieldNameTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation <span style='color:#808030; '>+</span> <span style='color:#008c00; '>20</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>60</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Comments:</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> fieldNameFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>fieldNameTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        fieldNameRectangle <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#800080; '>;</span>
        fieldBoundingRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>fieldNameRectangle<span style='color:#808030; '>.</span>Right <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>150</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>60</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the form field</span>
        PdfFormTextBox multilineTextBoxField <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Form<span style='color:#808030; '>.</span>AddTextBox<span style='color:#808030; '>(</span>pdfPage<span style='color:#808030; '>,</span> fieldBoundingRectangle<span style='color:#808030; '>,</span>
                <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Enter your comments here:\r\nFirst comment line\r\nSecond comment line</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> textFieldFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set unique form field name used when the form is submitted</span>
        multilineTextBoxField<span style='color:#808030; '>.</span>Name <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>comments</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set form field style </span>
        multilineTextBoxField<span style='color:#808030; '>.</span>Style<span style='color:#808030; '>.</span>BackColor <span style='color:#808030; '>=</span> Color<span style='color:#808030; '>.</span>AliceBlue<span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set the multiline mode for text box field</span>
        multilineTextBoxField<span style='color:#808030; '>.</span>IsMultiLine <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> yLocation <span style='color:#808030; '>+</span> <span style='color:#008c00; '>70</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add a form submit button to PDF form</span>
        fieldBoundingRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>75</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>15</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        PdfFormButton submitFormButton <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Form<span style='color:#808030; '>.</span>AddButton<span style='color:#808030; '>(</span>pdfPage<span style='color:#808030; '>,</span> fieldBoundingRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Submit</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> buttonTextFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set unique form field name used when the form is submitted</span>
        submitFormButton<span style='color:#808030; '>.</span>Name <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>submitFormButton</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set form field style </span>
        submitFormButton<span style='color:#808030; '>.</span>Style<span style='color:#808030; '>.</span>BackColor <span style='color:#808030; '>=</span> Color<span style='color:#808030; '>.</span>Beige<span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the form submit action</span>
        PdfSubmitFormAction submitFormAction <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> PdfSubmitFormAction<span style='color:#808030; '>(</span>submitUrlTextBox<span style='color:#808030; '>.</span>Text<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Form values will be submitted in HTML form format</span>
        submitFormAction<span style='color:#808030; '>.</span>Flags |<span style='color:#808030; '>=</span> PdfFormSubmitFlags<span style='color:#808030; '>.</span>ExportFormat<span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>getMethodRadioButton<span style='color:#808030; '>.</span>Checked<span style='color:#808030; '>)</span>
            submitFormAction<span style='color:#808030; '>.</span>Flags |<span style='color:#808030; '>=</span> PdfFormSubmitFlags<span style='color:#808030; '>.</span>GetMethod<span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set the form submit button action</span>
        submitFormButton<span style='color:#808030; '>.</span>Action <span style='color:#808030; '>=</span> submitFormAction<span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add a form reset button to PDF form</span>
        fieldBoundingRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation <span style='color:#808030; '>+</span> <span style='color:#008c00; '>100</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>75</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>15</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        PdfFormButton resetFormButton <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Form<span style='color:#808030; '>.</span>AddButton<span style='color:#808030; '>(</span>pdfPage<span style='color:#808030; '>,</span> fieldBoundingRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Reset</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> buttonTextFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set unique form field name used when the form is submitted</span>
        resetFormButton<span style='color:#808030; '>.</span>Name <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>resetFormButton</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set form field style </span>
        resetFormButton<span style='color:#808030; '>.</span>Style<span style='color:#808030; '>.</span>BackColor <span style='color:#808030; '>=</span> Color<span style='color:#808030; '>.</span>Beige<span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Create the form reset action</span>
        PdfResetFormAction resetFormAction <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> PdfResetFormAction<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#696969; '>// Set the form reset button action</span>
        resetFormButton<span style='color:#808030; '>.</span>Action <span style='color:#808030; '>=</span> resetFormAction<span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Save the PDF document in a memory buffer</span>
        <span style='color:#800000; font-weight:bold; '>byte</span><span style='color:#808030; '>[</span><span style='color:#808030; '>]</span> outPdfBuffer <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Save<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Send the PDF as response to browser</span>

        <span style='color:#696969; '>// Set response content type</span>
        Response<span style='color:#808030; '>.</span>AddHeader<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Content-Type</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>application/pdf</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Instruct the browser to open the PDF file as an attachment or inline</span>
        Response<span style='color:#808030; '>.</span>AddHeader<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Content-Disposition</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> String<span style='color:#808030; '>.</span>Format<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>attachment; filename=Create_PDF_Forms.pdf; size={0}</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> outPdfBuffer<span style='color:#808030; '>.</span>Length<span style='color:#808030; '>.</span>ToString<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Write the PDF document buffer to HTTP response</span>
        Response<span style='color:#808030; '>.</span>BinaryWrite<span style='color:#808030; '>(</span>outPdfBuffer<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// End the HTTP response and stop the current page processing</span>
        Response<span style='color:#808030; '>.</span>End<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>finally</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#696969; '>// Close the PDF document</span>
        pdfDocument<span style='color:#808030; '>.</span>Close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</span>